
import * as types from '../actions/actionTypes';

const initialState = {
    status: false,
    code: 0,
    message: '',
    user: {},
    share: {},
    isLoading: false,
    
    formItemList:[],
    formRemarkList: [],
    formTitle:'',
    formButtomName:'',
    formSubmitAction:'',

    withdrawList:[],
    chexianRateList:[],

    pageId:'',
    header:{},
    dom:[],
    hasSize:0,
    lastId:'',
    newestId:'',
    more:'',

    uiDownTopScrollable:true,
    uiTopDownScrollable:true,
    isLoadingMore:false,


};

let uiReducer = (state=initialState, action) => {
    switch (action.type) {
        case types.kPageIdSync:
            return {
                ...state,
                pageId:action.pageId,
            }; 
        case types.kSetDomTree:
            return {
                ...state,
                isLoading:true,
                isLoadingMore:true, 
            }; 
        case types.kSetPageHeaderReceived:
            return {
                ...state,
                header:action.header,
            }; 
        case types.kSetDomTreeReceived:
            return {
                ...state,
                isLoading:false,
                isLoadingMore:false, 
                lastId:action.lastId,
                newestId:action.newestId,
                dom:action.dom,
                header:action.header,
                hasSize:action.hasSize,
            };        
            case types.kSetDomTreeHeaderReceived://到页面头部，向下拉伸刷新数据
            return {
                ...state,
                isLoading:false,
                isLoadingMore:false, 
                lastId:action.lastId,
                newestId:action.newestId,
                dom:(action.dom.length=0)?action.dom.concat(state.dom):state.dom,
                hasSize:action.hasSize,
                
            };            
            case types.kSetDomTreeFooterReceived://到页面底部，向上拉伸刷新数据
            return {
                ...state,
                isLoading:false,
                isLoadingMore:false, 
                lastId:action.lastId,
                newestId:action.newestId,
                dom:(action.dom.length>0)?state.dom.concat(action.dom):state.dom,
                hasSize:action.hasSize,
            };            
            case types.kSetUIScrollable:
            return {
                ...state,
                uiTopDownScrollable:action.uiTopDownScrollable,
                uiDownTopScrollable:action.uiDownTopScrollable,
                
            };              
            case types.kSetIsLoadingMore:
            return {
                ...state,
                isLoadingMore:action.isLoadingMore
            };  
            
        default:
            return state;
    }
};

export default uiReducer;